package cn.wolfcode.trip.admin.controller;

import cn.wolfcode.trip.base.query.StrategyCommentQueryObject;
import cn.wolfcode.trip.base.service.IStrategyCommentService;
import cn.wolfcode.trip.base.util.JasonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/strategyComment")
public class StrategyCommentController {

    @Autowired
    private IStrategyCommentService strategyCommentService;

    /**
     * 列出所有的点评
     * @param qo
     * @param model
     * @return
     */
    @RequestMapping("/list.do")
    public String list(@ModelAttribute("qo") StrategyCommentQueryObject qo, Model model){
        model.addAttribute("pageInfo", strategyCommentService.selectForList(qo));
        return "strategyComment/list" ;
    }

    @RequestMapping("/delete.do")
    @ResponseBody
    public Object delete(Long id){
        JasonResult result = new JasonResult();
        try {
            if (id != null){
                strategyCommentService.delete(id);
            }
        } catch (Exception e) {
            result.mark(e.getMessage());
        }
        return result;
    }
}
